package com.chinasi.web.action;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.caland.framework.core.utils.ResponseUtils;
import com.caland.framework.core.utils.codehaus.json.JsonUtils;
import com.chinasi.model.BidBasic;
import com.chinasi.model.IndustryInfo;
import com.chinasi.model.ProjectInfo;
import com.chinasi.service.BidBasicService;
import com.chinasi.service.IndustryInfoService;
import com.chinasi.service.ProjectInfoService;
import com.chinasi.web.action.common.URLConstants;

@Controller
@RequestMapping(URLConstants.BID)
public class BidBasicAction {

	/**
	 * WowBidBasicService
	 */
	@Autowired
	private BidBasicService wowBidBasicService;
	
	@Autowired
	private IndustryInfoService industryInfoService;
	
	@Autowired
	private ProjectInfoService projectInfoService;
	
	/** 首页展示热门项目列表 */
	@RequestMapping("listHome")
	public ModelAndView list(HttpServletRequest request){
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("pager", wowBidBasicService.findPage(1));
		return new ModelAndView("bid_list",model);
	}
	
	/** 行业动态页面，标签检索招标信息 */
	@RequestMapping("prolistByTagserch")
	public ModelAndView findByTag(String tag){
		Map<String, Object> model = new HashMap<String, Object>();
//		model.put("pager", wowBidBasicService.findRelationByIndustry(tag, 1));
		model.put("pager", wowBidBasicService.findPage(1));
		return new ModelAndView("bid_tagSearchList",model);
	}
	
	/** 项目信息页分页展示 **/
	@RequestMapping("prolist")
	public ModelAndView prolist(HttpServletRequest request){
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("pager", wowBidBasicService.findPage(1));
		//行业动态
		model.put("infoList", industryInfoService.findPageCondition(new IndustryInfo(),1));
		
		
		//解决方案信息
		model.put("projectInfoList", projectInfoService.findPageCondition(new ProjectInfo(), 1));
		
		model.put("params", new BidBasic());
		return new ModelAndView("programInfo",model);
	}
	
	/** 异步加载项目 */
	@RequestMapping("loadajax")
	public ModelAndView loadajax(HttpServletRequest request, HttpServletResponse response, int curpage){
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("pager", wowBidBasicService.findPage(curpage));
		model.put("params", new BidBasic());
		return new ModelAndView("fragment/fragment_bid_more", model);
	}
	
}
